/**
 * 用户表格列
 */
import { ref, h } from 'vue'
import { user } from '../../../entity/system/user'
import { TableColumnProps } from '../../../components/base/table/table-props'
import { getFilePath } from '../../../utils/file-util'

export const columns: Array<TableColumnProps<user>> = [
  {
    title: '编号',
    customRender: ({ index }) => index + 1,
    width: 60,
    align: 'center',
  },
  {
    title: '用户名',
    dataIndex: 'name',
    width: 100,
  },
  {
    title: '昵称',
    dataIndex: 'nickName',
    width: 120,
  },
  {
    title: '头像',
    width: 100,
    dataIndex: 'avatar',
    align: 'center',
    customRender: ({ record }) =>
      h('img', {
        src: record?.avatar ? record?.avatar : '',
        width: '50',
        height: '50',
      }),
  },
  {
    title: '机构',
    width: 100,
    dataIndex: 'deptName',
  },
  {
    title: '邮箱',
    width: 200,
    dataIndex: 'email',
  },
  {
    title: '手机号',
    dataIndex: 'mobile',
    width: 170,
  },
  {
    title: '状态 0：禁用 1：正常 ',
    dataIndex: 'status',
    width: 190,
    customRender: ({ record }) => (record.status == 1 ? '正常' : '禁用'),
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    customRender: ({ record }) => (record.createTime ? record.createTime.replace('T', ' ') : ''),
    width: 200,
  },
  {
    title: '修改时间',
    dataIndex: 'lastUpdateTime',
    customRender: ({ record }) => (record.lastUpdateTime ? record.lastUpdateTime.replace('T', ' ') : ''),
    width: 200,
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: 200,
    align: 'center',
    fixed: 'right',
  },
]
